import { Component, OnInit, ViewChild } from '@angular/core';
import { _HttpClient, ModalHelper } from '@delon/theme';
import { STColumn, STComponent } from '@delon/abc';
import { SFSchema } from '@delon/form';

@Component({
  selector: 'app-archive-record',
  templateUrl: './record.component.html',
})
export class ArchiveRecordComponent implements OnInit {
  record: any = {};
  url = `/borrow/dt`;
  params: any = { status: `${this.record.id}` };
  searchSchema: SFSchema = {
    properties: {
      title: {
        type: 'string',
        title: '公文',
        ui: {
          placeholder: '编号/文号/文件标题',
        },
      },
      lender: {
        type: 'string',
        title: '借阅者',
        ui: {
          placeholder: '借阅者',
        },
      },
    }
  };
  @ViewChild('st') st: STComponent;
  columns: STColumn[] = [
    { title: '编号', index: 'no' },
    { title: '文号', index: 'code' },
    { title: '文件标题', index: 'title' },
    { title: '状态', index: 'status' },
    { title: '借阅者', index: 'lender' },
    { title: '借阅时间', type: 'date', index: 'lenderAt' },
    { title: '归还人', index: 'returner' },
    { title: '归还时间', type: 'date', index: 'returnAt' },
    // { title: '创建时间', type: 'date', index: 'createAt' },
    // {
    //   title: '',
    //   buttons: [
    //     {
    //       text: '删除', icon: 'delete', type: 'del', click: (record, modal, comp) => {
    //         this.http.post(`/borrow/delete?id=${record.id}`).subscribe((res) => {
    //           // this.message.success(`成功删除【${record.title}】`);
    //           this.st.reload();
    //         });
    //       }
    //     },
    //   ]
    // }
  ];

  constructor(private http: _HttpClient, private modal: ModalHelper) { }

  ngOnInit() { }

  add() {
    // this.modal
    //   .createStatic(FormEditComponent, { i: { id: 0 } })
    //   .subscribe(() => this.st.reload());
  }

}
